"""Annotated video writer (moved from io/)."""
import cv2  # type: ignore


class VideoWriter:
    def __init__(self, path: str, fps: float, size: tuple[int, int]):
        fourcc = cv2.VideoWriter_fourcc(*"mp4v")
        self.w = cv2.VideoWriter(path, fourcc, fps, size)
        if not self.w.isOpened():
            raise RuntimeError(f"Cannot open writer: {path}")

    def write(self, frame):
        self.w.write(frame)

    def release(self):
        self.w.release()

